<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="java.net.URLDecoder"%>
<%@ page import="com.cndatacom.ccsinfoMgr.model.*"%> 

<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="pg"  uri="http://jsptags.com/tags/navigation/pager" %>

<%
	String ctx = request.getContextPath();
	
	String showTitle = "";
	if(request.getParameter("title") != null) {
		showTitle = URLDecoder.decode(request.getParameter("title"), "UTF-8");
	}
	
	String title = "";
	if(request.getParameter("title") != null) {
		title = request.getParameter("title");
	}
	
	String fromTime = "";
	if(request.getParameter("fromtime") != null) {
		fromTime = request.getParameter("fromtime");
	}
	
	String toTime = "";
	if(request.getParameter("totime") != null) {
		toTime = request.getParameter("totime");
	}

%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>管理信息平台首页${title}</title>
<link rel="stylesheet" type="text/css" href="<%=ctx%>/infoMgr/css/main.css"/>
<link rel="stylesheet" type="text/css" href="<%=ctx%>/infoMgr/dropdown-menu/style.css"/>
<script type="text/javascript" src="<%=ctx%>/infoMgr/dropdown-menu/script.js"></script>
<script src="<%=ctx%>/js/gotoPage.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript" src="<%=ctx%>/js/My97DatePicker/WdatePicker.js"></script>
<script src="<%=ctx%>/js/submitFunctions.js" type="text/javascript"></script>

<script>
	function replaceAll(target) {
		target = target.replace(new RegExp("'","gm"),"");
		return target;
	}
	function queryDownloadInfo() {
	
		var title = document.getElementById("showtitle").value;
		if(title.indexOf("'") >= 0) {
			title = replaceAll(title);
		}

		if(title != "") {
			document.getElementById("title").value = encodeURI(title);
		}
		
		document.getElementById("queryForm").submit();
	}
</script>

</head>
<body>

<form name="downloadForm" action="download.action" method="post">
	<input type="hidden" name="filePaht" id="filepath"/>
	<input type="hidden" name="fileName" id="filename"/>
</form>

<!--主体内容开始-->
<div class="warp">
  <!--页头开始-->
  <%request.setAttribute("panel","index");%>
  <%request.setAttribute("conpanel","papers");%>
  <%@include file="common/include/panel.jsp" %>
  <!--页头结束-->
  <!--内容开始-->
  <div class="insidecontent">
    <%@include file="common/include/conpanel.jsp" %>
    <div class="formlist">
    <div class="bread">当前位置：<a href="index.action">首页</a> >> <a href="#">资料下载</a></div>
    	<input type="hidden" name="hql" id="hql"/>
    
    <form id="queryForm" name="queryForm" action="query-downloadinfo.action" method="get">
    
      <input type="hidden" name="title" id="title"/>
    	
      <table border="0" cellspacing="0" cellpadding="0" class="formT formS">
        <tr>
          <td class="Tlable">标题：</td>
          <td><input type="text" class="formText" id="showtitle" value="<%=showTitle%>"/></td>
        </tr>
        <tr>
          <td class="Tlable">发布时间：</td>
          <td><input class="Wdate" type="text" name="fromtime" value="<%=fromTime %>" id="fromtime" style="padding-left:2px" onClick="WdatePicker({skin:'YcloudRed',dateFmt:'yyyy-MM-dd HH:mm:ss'})">
            至
            <input class="Wdate" type="text" name="totime" value="<%=toTime %>" id="totime" style="padding-left:2px" onClick="WdatePicker({skin:'YcloudRed',dateFmt:'yyyy-MM-dd HH:mm:ss'})">
            <button class="formBt" onclick="queryDownloadInfo()">查询</button><button class="formBt" onclick="addDownloadInfo()">新建资料下载</button></td>
        </tr>
      </table>
	</form>
      <div class="container containerList">
     
		<c:if test="${!empty pm.resultList}">
			<ul>
				<c:forEach items="${pm.resultList}" var="info">
					<li>
						<a href="#" title="${info.title}" onclick="downloadFile('${info.attachment}','${fn:substring(info.attachment, 48, fn:length(info.attachment))}');return false;" class="resultList">${fn:substring(info.title, 0,100)}</a><button class="formBt" onclick="editDownloadInfo(${info.id});">编辑</button><button class="formBt" onclick="deleteDownloadInfo(${info.id});">删除</button>
					</li>
				</c:forEach>
			</ul>
		  <div class="new_pages">
			<!-- 插入分页导航条 -->
            <pg:pager url="query-downloadinfo.action" maxPageItems="${pm.perPageRecordNum}" items="${pm.recordSum}" export="currentPageNumber=pageNumber">
				<pg:param name="title" value="<%=title%>"/>
				<pg:param name="fromtime" value="<%=fromTime %>"/>
				<pg:param name="totime" value="<%=toTime %>"/>
				<pg:first>
					<a href="${pageUrl}">[ 首页]</a>|
				</pg:first>
				<pg:prev ifnull="true">
					<% if (pageUrl != null) { %>   
        				<a HREF="<%=pageUrl%>">上一页</a>|
      				<% } else { %>   
        				&nbsp;上一页  |   
      				<% } %>   
				</pg:prev>
				<pg:next ifnull="true">
					<% if (pageUrl != null) { %>   
        				<a HREF="<%=pageUrl%>">下一页</a>|
      				<% } else { %>   
        				&nbsp;下一页  |   
      				<% } %> 
				</pg:next>
				<pg:last>
					<a href="${pageUrl}">[ 末页]</a>
					第<span class="new_point"><%=currentPageNumber%>/<%=pageNumber%></span>页 
					每页${pm.perPageRecordNum}条 共<%=pageNumber%>页 
					到第<input type="text" name="pageNo" id="pageNo" size="1">页<a href="#"><img src="<%=ctx%>/infoMgr/images/ico_pages.gif" alt="" onclick="gotoPageQuery(${pm.recordSum},${pm.perPageRecordNum})"/></a>
				</pg:last>
			</pg:pager>
		</div>
      </c:if>
      </div>
    </div>
    <!--内容结束-->
  </div>
    <!--页脚开始-->
    <div class="footer"><span>Copyright© 2009-2010 中国通信服务股份有限公司 版权所有</span></div>
    <!--页脚结束-->
</div>
<!--主体内容结束-->
<script type="text/javascript">
	var menu=new menu.dd("menu");
	menu.init("menu","menuhover");
	
	function deleteDownloadInfo(id) {
		if(confirm('确定删除吗？')) {
			window.location.href = "downloadinfo-delete.action?downloadInfo.id="+id;
		}
	}
	
	function editDownloadInfo(id) {
		window.location.href = "downloadinfo-find.action?downloadInfo.id="+id;
	}
	
	function addDownloadInfo() {
		window.location.href = "downloadinfo-edit.action";
	}
</script>
</body>
</html>